n,s=map(int,input().split())
v=list(map(int,input().strip().split()))
c=sum(v)
if c<s:print(-1)
else:print(min((c-s)//n,min(v)))
//Deeva
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <iomanip>
#include <algorithm>
using namespace std;
#define ll long long int
ll bot=1;
int main()
{
ll n,s,mini=INT_MAX,a=0,b=0;
cin>>n>>s;
vector<ll> v(n,0);
for(ll i=0;i<n;i++)
{
cin>>v[i];
mini=min(mini,v[i]);
a=a+v[i];
}
if(a<s)
{
cout<<"-1";
return 0;
}
for(ll i=0;i<n;i++)
{
b=b+v[i]-mini;
}
b=s-b;
if(b<0)
{
cout<<mini;
return 0;
}
a=b%n;
b=b/n;
if(a!=0)
{
b++;
}
cout<<mini-b;
}
Going to office | Color the boxes |
Missing numbers | Maximum sum |
13 Reasons Why | Friend's Relationship |
Health of a person | Divisibility |
A. Movement | Numbers in a matrix |
Sequences | Split houses |
Divisible | Three primes |
Coprimes | Cost of balloons |
One String No Trouble | Help Jarvis! |
Lift queries | Goki and his breakup |
Ali and Helping innocent people | Book of Potion making |
Duration | Birthday Party |
e-maze-in | Bricks Game |
Char Sum | Two Strings |
Anagrams | Prime Number |